package com.trkj.focusonzhuzhou.user;

import com.trkj.focusonzhuzhou.R;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.webkit.WebView.FindListener;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.PopupWindow;
import android.widget.TextView;

public class UserManagerFragment extends Fragment {

	private TextView tvUserName;
	private LinearLayout root;
	private TextView tvUpdateDocumenter;
	private TextView tvUpdatePassword;
	private TextView tvMyCollection;
	private TextView tvMyComment;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		
		if(root == null){
			root = (LinearLayout) inflater.inflate(R.layout.user_manager, null);
			tvUserName = (TextView) root.findViewById(R.id.tv_user_name);
			tvUserName.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View arg0) {
					Intent intent = new Intent(getActivity(),LoadingActivity.class);
					startActivity(intent);
				}
			});
			
			
			tvUpdateDocumenter = (TextView) root.findViewById(R.id.tv_update_documenter);
			tvUpdateDocumenter.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View arg0) {
					Intent intent = new Intent(getActivity() , 
							UpdateDocumenterActivity.class);
					
					startActivity(intent);
				}
			});
			
			tvUpdatePassword = (TextView) root.findViewById(R.id.tv_update_password);
			tvUpdatePassword.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View arg0) {
					Intent intent = new Intent(getActivity() , 
							UpdatePasswordActivity.class);
					
					startActivity(intent);
				}
			});
			
			
			tvMyCollection = (TextView) 
					root.findViewById(R.id.tv_user_collection);
			
			tvMyCollection.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View arg0) {
					Intent intent = new Intent(getActivity() , 
							MyCollectionActivity.class);
					
					startActivity(intent);
				}
			});
			
			tvMyComment = (TextView)
					root.findViewById(R.id.tv_user_content);
			tvMyComment.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View arg0) {
					Intent intent = 
							new Intent(getActivity() , MyCommentActivity.class);
					startActivity(intent);
				}
			});
		}
		
		ViewGroup parent  = (ViewGroup) root.getParent();
		if(parent != null){
			parent.removeAllViews();
		}
		
		return root;
	}
	
	
}
